home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1140 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: jsa@edg.com (J. Stephen Adamczyk)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: 'const' binding to specifier in declaration list
  5. Date: 17 Apr 1996 11:31:42 PDT
  6. Organization: Edison Design Group Inc.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <Dq0qGt.8Kz@edg.com>
  9. References: <3173B383.41C67EA6@rstcorp.com> <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Wed, 17 Apr 1996 18:10:04 GMT
  12. Apparently-To: comp-std-c++@uunet.uu.net
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMXU5D0y4NqrwXLNJAQFP7QIAxipo1dcPyyfEMpXxR49mu1LNhBW06SYs
  15.     NjEVMR8Qa2THd5JRqBlWX1njXmR5vaBH9R9VaAnF/pX8kq6WBeFcPg==
  16.     =rmNV
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de> kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
  20. >In article <3173B383.41C67EA6@rstcorp.com> "Aaron S. Binns"
  21. ><asbinn@rstcorp.com> writes:
  22. >|> I recently came across a piece of code that reads:
  23. >
  24. >|> class A {
  25. >|>   // contents of class A
  26. >|> } a1, *a2, const *a3;
  27. >
  28. >While I personally wouldn't write anything like this, it is definitly
  29. >legal.
  30.  
  31. No, I'm sorry, that's not true.  This little syntactic oddity is something
  32. accepted by the Microsoft compiler, but it's not standard C or C++.
  33. The part that gets repeated in a declaration comma list is the declarator,
  34. and the cv-qualifiers can only appear following a pointer or pointer-to-member
  35. declarator in the declarator syntax.
  36.  
  37. A little research with the Microsoft compiler suggests that:
  38.  
  39.   int i, const j, const *k;  // Declares j as "const int", k as "int *"
  40.  
  41. So the "const" above does nothing.  But that is outside the scope of
  42. comp.std.c++.
  43.  
  44. Steve Adamczyk
  45. Edison Design Group
  46. ---
  47. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  48.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  49.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  50.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  51.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  52. ]
  53.